//
//  ViewController.m
//  YYSliderTabProject
//
//  Created by 蓓蕾 on 2021/7/16.
//

#import "ViewController.h"
#import "YYAutoSliderViewController.h"
#import "YYFixSliderViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    NSLog(@"已启动");
    [self initAction];
}

-(void)initAction
{
    UIButton *autoAction = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:autoAction];
    [autoAction setTitle:@"固定宽度" forState:UIControlStateNormal];
    [autoAction setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    autoAction.titleLabel.font = [UIFont systemFontOfSize:15];
    [autoAction addTarget:self action:@selector(actionClicked:) forControlEvents:UIControlEventTouchUpInside];
    autoAction.frame = CGRectMake(kScreenWidth / 2 - 50, 100, 100, 50);
    autoAction.tag = 1;
    
    UIButton *fixAction = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:fixAction];
    [fixAction setTitle:@"屏幕宽度" forState:UIControlStateNormal];
    [fixAction setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    fixAction.titleLabel.font = [UIFont systemFontOfSize:15];
    [fixAction addTarget:self action:@selector(actionClicked:) forControlEvents:UIControlEventTouchUpInside];
    fixAction.frame = CGRectMake(CGRectGetMinX(autoAction.frame), CGRectGetMaxY(autoAction.frame) + 20, CGRectGetWidth(autoAction.bounds), CGRectGetHeight(autoAction.bounds));
    fixAction.tag = 2;
    
    UIButton *fixSliderAction = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:fixSliderAction];
    [fixSliderAction setTitle:@"固定滑块宽度" forState:UIControlStateNormal];
    [fixSliderAction setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    fixSliderAction.titleLabel.font = [UIFont systemFontOfSize:15];
    [fixSliderAction addTarget:self action:@selector(actionClicked:) forControlEvents:UIControlEventTouchUpInside];
    fixSliderAction.frame = CGRectMake(CGRectGetMinX(autoAction.frame), CGRectGetMaxY(fixAction.frame) + 20, CGRectGetWidth(autoAction.bounds), CGRectGetHeight(autoAction.bounds));
    fixSliderAction.tag = 3;
    
}

-(void)actionClicked:(UIButton *)sender
{
    NSInteger tag = sender.tag;
    if (tag == 1) {//固定宽度
        YYFixSliderViewController *fixTabVC = [[YYFixSliderViewController alloc] init];
        fixTabVC.currentIndex = 1;
        fixTabVC.navigationItem.title = @"固定宽度";
        [self.navigationController pushViewController:fixTabVC animated:YES];
    }
    else if (tag == 2)
    {//屏幕宽度
        YYAutoSliderViewController *autoTabVC = [[YYAutoSliderViewController alloc] init];
        autoTabVC.currentIndex = 1;
        autoTabVC.navigationItem.title = @"屏幕宽度";
        [self.navigationController pushViewController:autoTabVC animated:YES];
    }
    else
    {//固定滑块宽度
        YYFixSliderViewController *fixSliderVC = [[YYFixSliderViewController alloc] init];
        fixSliderVC.currentIndex = 1;
        fixSliderVC.navigationItem.title = @"固定滑块宽度";
        [self.navigationController pushViewController:fixSliderVC animated:YES];
    }
}


@end
